<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Menu_bar extends Page_Controller {

    function Menu_bar() {
        parent::Page_Controller();
        $CI = & get_instance();
        $CI->load->module_define('menus');
        $CI->load->module_model('menus.menu');
    }

    function index() {
        $CI = & get_instance();
        $CI->load->module_define('users');

        $CI->load->module_library('users.auth');
        $auth_data = $CI->auth->get_auth_data();
        if($CI->auth->is_superadmin()) {
            $menu = new stdClass();
            $menu->id = 1;
            $menu->name = 'HOME';
            $menu->admin_menu_link = 'home';
            $menu->children = array();
            $menus[] = $menu;

            $menu = new stdClass();
            $menu->id = 2;
            $menu->name = 'USERS';
            $menu->admin_menu_link = 'users';
            $menu->children = array();
            $menus[] = $menu;

            $menu = new stdClass();
            $menu->id = 3;
            $menu->name = 'FRANCHISE';
            $menu->admin_menu_link = 'franchises.s_franchises';
            $menu->children = array();
            $menus[] = $menu;

            $menu = new stdClass();
            $menu->id = 4;
            $menu->name = 'MIGRATE';
            $menu->admin_menu_link = 'franchises.s_franchises.migrate';
            $menu->children = array();
            $menus[] = $menu;

            $menu = new stdClass();
            $menu->id = 5;
            $menu->name = 'THEMES';
            $menu->admin_menu_link = 'page2_css.page2_css.lists';
            $menu->children = array();
            $menus[] = $menu;
            
            $menu = new stdClass();
            $menu->id = 6;
            $menu->name = 'SEND MAILS';
            $menu->admin_menu_link = 'franchises.s_franchises.send_mails';
            $menu->children = array();
            $menus[] = $menu;

            /*$menu = new stdClass();
            $menu->id = 6;
            $menu->name = 'EXPORT';
            $menu->admin_menu_link = 'franchises.s_franchises.export';
            $menu->children = array();
            $menus[] = $menu;*/

            $this->add('is_supperadmin', 1);
        }else {
            $CI->menu->_sort_field = 'ordering';
            $CI->menu->_sort_type = 0;
            $menus = $CI->menu->menus_recursive();
            $auth_data = $CI->auth->get_auth_data();
            $this->add('admin_id', $auth_data['admin_id']);
        }
        $this->add('menus', $menus);
    }
}